<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="Content-Security-Policy"
    content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';">
  <title>设置</title>
</head>
<style>
  html,
  body {
    padding: 0;
    margin: 0;
    /* overflow: hidden; */
  }

  body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
  }

  .navbar {
    background-color: #f1f1f1;
    padding: 10px;
    position: relative;
  }

  #dropdown-btn {
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 8px 16px;
  }

  #dropdown-btn:hover {
    background-color: #ddd;
  }

  .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    border: 1px solid #ccc;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
  }

  .dropdown-menu ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
  }

  .dropdown-menu ul li {
    padding: 8px 16px;
  }

  .dropdown-menu ul li a {
    text-decoration: none;
    color: #333;
    display: block;
  }

  .dropdown-menu ul li:hover {
    background-color: #f1f1f1;
  }
</style>

<body>
  <div class="navbar">
    <button id="dropdown-btn">File</button>
    <div id="dropdown-menu" class="dropdown-menu">
      <ul>
        <li><a href="#">New File</a></li>
        <li><a href="#">Open</a></li>
        <li><a href="#">Save</a></li>
        <li><a href="#">Exit</a></li>
      </ul>
    </div>
  </div>
</body>
<script>
  const dropdownBtn = document.getElementById('dropdown-btn');
  const dropdownMenu = document.getElementById('dropdown-menu');

  // 点击按钮时切换下拉框的显示状态
  dropdownBtn.addEventListener('click', () => {
    if (dropdownMenu.style.display === 'block') {
      dropdownMenu.style.display = 'none';
    } else {
      dropdownMenu.style.display = 'block';
    }
  });

  // 点击页面其他区域时隐藏下拉框
  document.addEventListener('click', (event) => {
    if (!dropdownBtn.contains(event.target)) {
      dropdownMenu.style.display = 'none';
    }
  });
</script>

</html>